package GuessGame;

//import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

public class GuessGameTest {
	
	static char[] bchar;
	static char[] ichar;
	
	static int iNum;
	static int letterNum = 26;
	
	static int bscore = 10;
	static int sscore = 5;
	//static int count = 0;
	
	
	static boolean[] flag = new boolean[letterNum];//建立一个flag
	public static void main(String[] args) {
		
		
		gameStart();
	}
	

	public static int inputInt(){
		
		Scanner scan = new Scanner(System.in);
		while(true)
		{
			iNum = scan.nextInt();
			if((iNum>letterNum)||(iNum<=0))
				System.out.println("请重新输入");
			else 
				break;
		}
		int num = iNum;
		scan = new Scanner(System.in);//scan.close();
		return num;
	}
	
	
	public static void buildChar(){//生成随机字符数组
		Random ran = new Random();// 生成随机数种子
		//初始化bchar
		bchar = new char[iNum];//12
		int tmp = 0;
		for(int i = 0; i < bchar.length; ++i)
		{
			do{ 
				tmp = ran.nextInt(letterNum);
				
			}while(flag[tmp]==true);
			flag[tmp]=true;
			bchar[i] = (char)(tmp+65);
		}
		
		System.out.println(Arrays.toString(bchar));
		//return bchar;
	}
	
	
	public static void inputChar(){ //输入字符数组
		Scanner scan1 = new Scanner(System.in);
		String tmp = scan1.next().trim().toUpperCase();//= new String();
		ichar =tmp.toCharArray();
		//System.out.println(Arrays.toString(ichar));
		scan1 = new Scanner(System.in);
		//return ichar;
	}

	
	public static int[] check(){ //字符数组比对
		int[] res = new int[2];
		for(int i = 0; i < bchar.length; ++i)
		{
			for(int j = 0; j < ichar.length; ++j)
			{
				if((ichar[j] == bchar[i])&&(i == j))
				{
					res[0]++; 
					//count++; 
				}
				else if((ichar[j] == bchar[i])&&(i != j))
				{
					res[1]++;
					//count++;
				}
			}
		}
		System.out.println("猜对字母个数: "+(res[0]+res[1]));
		System.out.println("位置正确的有: "+res[0]);
		return res;
	}
	
	
	public static void print(){ //输出分值
		int[] res =check();
	
		System.out.println("总分为: " +(res[0]*bscore+res[1]*sscore));
	}
	public static void gameStart()
	{ 
		
		inputInt();
		buildChar();
		int tmp =inputInt();
		for(int i = 0; i < tmp; ++i)
		{
			inputChar();
			check();
		}
		print();
	}
}
	

